﻿#pragma once
#include "function.h"


Function::Function(QDialog* parent, QString path_in, int camera_index) : QDialog(parent)
{
    m_path_para = path_in;
    m_section = "common";
    m_camera_index = camera_index;


    m_model_image_path = path_in.left(path_in.length()-4)  + ".png";
    m_image = imread(m_model_image_path.toLocal8Bit().toStdString(), IMREAD_UNCHANGED);
    if (m_image.empty())
    {
//        //QMessageBox::information(nullptr, m_model_image_path, "加载模板图像错误");
    }


    m_qsettings = new QSettings(path_in, QSettings::IniFormat);

    m_function_blob_match = new FunctionBlobMatch(this, m_qsettings, "function_blob_match");
    m_function_blob_match->m_image = m_image;
    m_function_blob_match->create_model();
    connect(m_function_blob_match,&FunctionBlobMatch::saveImage,this,&Function::saveImage);

    m_measure_electrode = new MeasureElectrode(this, m_qsettings, "measure_electrode");

    m_detection_electrode_rect_left = new DetectionThreshold(this, m_qsettings, "detection_electrode_left");

    m_detection_electrode_rect_right = new DetectionThreshold(this, m_qsettings, "detection_electrode_right");

    m_detection_hsv =  new DetectionThreshold(this, m_qsettings, "m_detection_hsv");
    m_detection_rgb1 = new DetectionThreshold(this, m_qsettings, "m_detection_rgb1");

	m_detection_rgb2 = new DetectionThreshold(this, m_qsettings, "m_detection_rgb2");
	m_detection_rgb3 = new DetectionThreshold(this, m_qsettings, "m_detection_rgb3");
	m_detection_rgb4 = new DetectionThreshold(this, m_qsettings, "m_detection_rgb4");
	m_detection_rgb5 = new DetectionThreshold(this, m_qsettings, "m_detection_rgb5");


    m_function_dl_3 = new Detection_dl_3(this, m_qsettings, "m_function_dl_" + QString::number(camera_index));
    m_function_dl_3->m_image = m_image;



    m_detection_gray =  new DetectionGRAY(this, m_qsettings, "m_detection_gray");

    QString msg;



    //m_detection_character->m_model_image_path = m_model_image_path;

    this->setWindowTitle("检测");
    QRect desktop_rect = QApplication::desktop()->geometry();
    double ratio_x = desktop_rect.width() / 1920.0;
    double ratio_y = desktop_rect.height() / 1080.0;

    move(0, 0);
    setFixedSize(1920 * ratio_x, 1010 * ratio_y);


    m_listview = new QListView(this);
    m_listview->setSelectionBehavior(QAbstractItemView::SelectRows);	// 设置选择行为时每次选择一行
    m_listview->setEditTriggers(QAbstractItemView::NoEditTriggers);		// 设置不可编辑
    //m_listview->setStyleSheet("selection-background-color:lightblue;");	// 设置选中背景色
    m_listview->setGeometry(400 * ratio_x, 0, 240*ratio_x, 800 * 1.2 * ratio_y);
    m_listview_model = new QStringListModel();
    m_listview->setModel(m_listview_model);
    connect(m_listview, &QListView::clicked, this, &Function::listViewClick);

    m_view = new MyQGraphicsView(this);
    m_view->setGeometry(660 * ratio_x, 0, 1000 * 1.25 * ratio_x, 800 * 1.25 * ratio_y);


//    m_view->m_graphics_shape_rect = new GraphicsShapeRect(100,100,100,100);
//    m_view->m_scene->addItem(m_view->m_graphics_shape_rect);
//    QRectF qrectf = m_view->m_graphics_shape_rect->boundingRect();
//    connect(m_view->m_graphics_shape_rect, &GraphicsShapeRect::sendMessage, m_view->m_pixmapItem, &MyQGraphicsPixmapItem::receiveMessage);



    QSize control_size(150 * ratio_x, 40 * ratio_y);

    QWidget* p = new QWidget(this);
    p->move(0 * ratio_x, 0 * ratio_y);
    p->setFixedSize(400 * ratio_x, 800 * ratio_y);

    QGridLayout* qgridLayout = new QGridLayout();
    p->setLayout(qgridLayout);

    int index = 0;



    QSize ButtonSize(180 * ratio_x, 40 * ratio_y);

    m_pushbutton_load_image = new QPushButton(this);
    m_pushbutton_load_image->setText("载入单张图像");
    m_pushbutton_load_image->setFixedSize(ButtonSize);
    connect(m_pushbutton_load_image, &QPushButton::clicked, this, [=]() {
        QString filename;
        filename = QFileDialog::getOpenFileName(this,
            tr("选择图像"),
            "",
            tr("Images (*.png *.bmp *.jpg)"));
        if (filename.isEmpty())
        {
            return;
        }

        m_image = imread(filename.toLocal8Bit().toStdString(), IMREAD_UNCHANGED);



        if (m_image.empty())
        {
//            //QMessageBox::information(nullptr, "", "加载检测图像错误");
            return;
        }
        m_function_blob_match->m_image = m_image;
        m_detection_character->m_image = m_image;
        QImage q_image = matToQImage(m_image);
        m_view->setImage(q_image, "");
        });
    qgridLayout->addWidget(m_pushbutton_load_image, index, 0);

    m_pushbutton_load_dir = new QPushButton(this);
    m_pushbutton_load_dir->setText("载入图像目录");
    m_pushbutton_load_dir->setFixedSize(ButtonSize);
    connect(m_pushbutton_load_dir, &QPushButton::clicked, this, [=]() {
        QString directory;

        directory = QFileDialog::getExistingDirectory(this,
            tr("选择文件夹"),
            "");
        if (directory.isEmpty())
        {
            return;
        }

        QDir dir(directory);
        dir.setFilter(QDir::Files | QDir::NoSymLinks);
        QStringList filters;
        filters << "*.bmp" << "*.jpg" << "*.png";
        dir.setNameFilters(filters);



        QStringList  string_list = dir.entryList();
        QStringList string_list_path;
        foreach(QString  var, string_list) {
            string_list_path << directory + "/" + var;
        }

        m_listview_model->setStringList(string_list_path);
        });

    qgridLayout->addWidget(m_pushbutton_load_dir, index, 1);
    index++;

	m_pushbutton_load_ok_dir = new QPushButton(this);
    m_pushbutton_load_ok_dir->setText("保存最近20张图像");
	m_pushbutton_load_ok_dir->setFixedSize(ButtonSize);
	connect(m_pushbutton_load_ok_dir, &QPushButton::clicked, this, [=]() {
//			QString dir_name = QString::number(m_camera_index) + "/ok/";
            QString dir_name = QString::number(m_camera_index) + "/";
			QDir dir(dir_name);
			dir.removeRecursively();
	
			if (!dir.exists())
			{
				QDir().mkpath(dir_name);
			}
            for (int i = 0; i < m_save_ok_vector_mat.size(); i++) {
				QString path = dir_name + QString("/%1.png").arg(i, 3, 10, QChar('0'));
	
				imwrite(path.toLocal8Bit().toStdString(), m_save_ok_vector_mat[i]);
			}
	
	
            dir.setFilter(QDir::Files | QDir::NoSymLinks);
            QStringList filters;
            filters << "*.bmp" << "*.jpg" << "*.png";
            dir.setNameFilters(filters);
	
            QStringList  string_list = dir.entryList();
            QStringList string_list_path;
            foreach(QString  var, string_list) {
                string_list_path << dir_name + "/" + var;
            }
            m_listview_model->setStringList(string_list_path);

		
	});
	qgridLayout->addWidget(m_pushbutton_load_ok_dir, index, 0);

	m_pushbutton_load_ng_dir = new QPushButton(this);
    m_pushbutton_load_ng_dir->setText("保存最近20张ng图像");
	m_pushbutton_load_ng_dir->setFixedSize(ButtonSize);
	connect(m_pushbutton_load_ng_dir, &QPushButton::clicked, this, [=]() {
		QString dir_name =  QString::number(m_camera_index) + "/ng/";
		QDir dir(dir_name);
		dir.removeRecursively();


		if (!dir.exists())
		{
			QDir().mkpath(dir_name);
		}
//        QMessageBox::information(nullptr, "", QString::number(m_save_ng_vector_mat.size()));
        for (int i = 0; i < m_save_ng_vector_mat.size();i++) {
			QString path = dir_name + QString("/%1.png").arg(i, 3, 10, QChar('0'));

//            if(m_save_ng_vector_mat[i].empty()==true)
//                QMessageBox::information(nullptr, "", "图像为空");
//            imshow("", m_save_ng_vector_mat[i]);
//            QMessageBox::information(nullptr, "", path);
			imwrite(path.toLocal8Bit().toStdString(), m_save_ng_vector_mat[i]);
		}

		
        dir.setFilter(QDir::Files | QDir::NoSymLinks);
        QStringList filters;
        filters << "*.bmp" << "*.jpg" << "*.png";
        dir.setNameFilters(filters);

        QStringList  string_list = dir.entryList();
        QStringList string_list_path;
        foreach(QString  var, string_list) {
            string_list_path << dir_name + "/" + var;
        }

        m_listview_model->setStringList(string_list_path);
	});

	qgridLayout->addWidget(m_pushbutton_load_ng_dir, index, 1);
	index++;



    m_pushbutton_open_model_image = new QPushButton(this);
    m_pushbutton_open_model_image->setText("打开模板图像");
    m_pushbutton_open_model_image->setFixedSize(ButtonSize);
    connect(m_pushbutton_open_model_image, &QPushButton::clicked, this, [=]() {

        m_image = imread(m_model_image_path.toLocal8Bit().toStdString(), IMREAD_UNCHANGED);
        if (m_image.empty())
        {
//            //QMessageBox::information(nullptr, "", "加载检测图像错误");
            return;
        }
        m_function_blob_match->m_image = m_image;
        m_detection_character->m_image = m_image;
        QImage q_image = matToQImage(m_image);
        m_view->setImage(q_image, "");

        });
    qgridLayout->addWidget(m_pushbutton_open_model_image, index, 0);


    m_pushbutton_save_model_image = new QPushButton(this);
    m_pushbutton_save_model_image->setText("存储模板图像");
    m_pushbutton_save_model_image->setFixedSize(ButtonSize);
    connect(m_pushbutton_save_model_image, &QPushButton::clicked, this, [=]() {

        if (m_image.empty())
        {
            //QMessageBox::information(nullptr, "", "加载图像错误");
            return;
        }

        m_function_blob_match->m_image = m_image;
        m_detection_character->m_image = m_image;

        imwrite(m_model_image_path.toLocal8Bit().toStdString(), m_image);
        //QMessageBox::information(nullptr, "", "存储模板图像OK");

        });
    qgridLayout->addWidget(m_pushbutton_save_model_image, index, 1);



//    index++;
//    m_qlabel_row1 = new QLabel();
//    m_qlabel_row1->setText("ROI起始点y坐标");
//    m_qlabel_row1->setFixedSize(control_size);
//    qgridLayout->addWidget(m_qlabel_row1, index, 0);
//    m_qspinbox_row1 = new QSpinBox();
//    m_qspinbox_row1->setFixedSize(control_size);
//    m_qspinbox_row1->setMinimum(0);
//    m_qspinbox_row1->setMaximum(1000);
//    qgridLayout->addWidget(m_qspinbox_row1, index, 1);



//    index++;
//    m_qlabel_column1 = new QLabel();
//    m_qlabel_column1->setText("ROI起始点x坐标");
//    m_qlabel_column1->setFixedSize(control_size);
//    qgridLayout->addWidget(m_qlabel_column1,index,0);
//    m_qspinbox_column1 = new QSpinBox();
//    m_qspinbox_column1->setFixedSize(control_size);
//    m_qspinbox_column1->setMinimum(0);
//    m_qspinbox_column1->setMaximum(1000);
//    qgridLayout->addWidget(m_qspinbox_column1, index, 1);

//    index++;
//    m_qlabel_row2 = new QLabel();
//    m_qlabel_row2->setText("ROI结束点y坐标");
//    m_qlabel_row2->setFixedSize(control_size);
//    qgridLayout->addWidget(m_qlabel_row2, index, 0);
//    m_qspinbox_row2 = new QSpinBox();
//    m_qspinbox_row2->setFixedSize(control_size);
//    m_qspinbox_row2->setMinimum(0);
//    m_qspinbox_row2->setMaximum(1000);
//    qgridLayout->addWidget(m_qspinbox_row2, index, 1);
//    index++;

//    m_qlabel_column2 = new QLabel();
//    m_qlabel_column2->setText("ROI结束点x坐标");
//    m_qlabel_column2->setFixedSize(control_size);
//    qgridLayout->addWidget(m_qlabel_column2,index,0);
//    m_qspinbox_column2 = new QSpinBox();
//    m_qspinbox_column2->setFixedSize(control_size);
//    m_qspinbox_column2->setMinimum(0);
//    m_qspinbox_column2->setMaximum(1000);
//    qgridLayout->addWidget(m_qspinbox_column2, index, 1);

//    index++;

//    m_pushbutton_set_roi = new QPushButton(this);
//    m_pushbutton_set_roi->setFixedSize(control_size);
//    m_pushbutton_set_roi->setText("获取界面上的ROI");
//    connect(m_pushbutton_set_roi, &QPushButton::clicked, this, [=]() {
//        QRectF qrectf = m_view->m_graphics_shape_rect->boundingRect();
//        m_qspinbox_row1->setValue(m_view->m_graphics_shape_rect->pos().y() + (int)qrectf.y());
//        m_qspinbox_column1->setValue(m_view->m_graphics_shape_rect->pos().x() + (int)qrectf.x());
//        m_qspinbox_row2->setValue(m_view->m_graphics_shape_rect->pos().y() + (int)(qrectf.y() + qrectf.height()));
//        m_qspinbox_column2->setValue(m_view->m_graphics_shape_rect->pos().x() + (int)(qrectf.x() + qrectf.width()));
//        });
//    qgridLayout->addWidget(m_pushbutton_set_roi, index, 0);
    index++;
    m_pushbutton_blob_math = new QPushButton(this);
    m_pushbutton_blob_math->setFixedSize(control_size);
    m_pushbutton_blob_math->setText("电极定位");
    connect(m_pushbutton_blob_math, &QPushButton::clicked, this, [=]() {
        m_function_blob_match->m_image = m_image;
         m_function_blob_match->showDialog();
        m_function_blob_match->show();
        });
    qgridLayout->addWidget(m_pushbutton_blob_math, index, 0);

    m_qcombobox_unuse_use = new QComboBox(this);
    m_qcombobox_unuse_use->setFixedSize(control_size);
    m_qcombobox_unuse_use->addItem("不启动电极定位检测");
    m_qcombobox_unuse_use->addItem("启动电极定位检测");
    qgridLayout->addWidget(m_qcombobox_unuse_use, index, 1);

    index++;

    m_pushbutton_measure_electrode = new QPushButton(this);
    m_pushbutton_measure_electrode->setFixedSize(control_size);
    m_pushbutton_measure_electrode->setText("电极测量");
    connect(m_pushbutton_measure_electrode, &QPushButton::clicked, this, [=]() {
        QString message;
        HObject image = matToHImage(m_image);
        bool state = m_function_blob_match->detection(image, message);
        if (state)
        {

            m_measure_electrode->image_in = m_function_blob_match->hobject_out;

            m_measure_electrode->region = m_function_blob_match->region_out;

            m_measure_electrode->showDialog();
            m_measure_electrode->show();
        }
        else
        {
            //QMessageBox::information(nullptr, "电极定位和提取出错", message);
            return;

        }

        });
    qgridLayout->addWidget(m_pushbutton_measure_electrode, index, 0);

    m_qcombobox_unuse_use_measure_electrode = new QComboBox(this);
    m_qcombobox_unuse_use_measure_electrode->setFixedSize(control_size);
    m_qcombobox_unuse_use_measure_electrode->addItem("电极测量不启动");
    m_qcombobox_unuse_use_measure_electrode->addItem("电极测量启动");
    qgridLayout->addWidget(m_qcombobox_unuse_use_measure_electrode, index, 1);

    index++;

    m_pushbutton_detection_electrode_left = new QPushButton(this);
    m_pushbutton_detection_electrode_left->setFixedSize(control_size);
    m_pushbutton_detection_electrode_left->setText("左电极检测");
    connect(m_pushbutton_detection_electrode_left, &QPushButton::clicked, this, [=]() {
        QString message;
        HObject image = matToHImage(m_image);
        bool state = m_function_blob_match->detection(image, message);
        if (state)
        {

            m_detection_electrode_rect_left->image_in = m_function_blob_match->hobject_out;
            m_detection_electrode_rect_left->showDialog();
			m_detection_electrode_rect_left->show();
        }
        else
        {
            //QMessageBox::information(nullptr, "电极定位和提取出错", message);
            return;

        }

        });
    qgridLayout->addWidget(m_pushbutton_detection_electrode_left, index, 0);

    m_qcombobox_unuse_use_detection_electrode_left = new QComboBox(this);
	m_qcombobox_unuse_use_detection_electrode_left->setFixedSize(control_size);
	m_qcombobox_unuse_use_detection_electrode_left->addItem("左电极检测不启动");
	m_qcombobox_unuse_use_detection_electrode_left->addItem("左电极检测启动");
    qgridLayout->addWidget(m_qcombobox_unuse_use_detection_electrode_left, index, 1);

    index++;

	m_pushbutton_detection_electrode_right = new QPushButton(this);
	m_pushbutton_detection_electrode_right->setFixedSize(control_size);
	m_pushbutton_detection_electrode_right->setText("右电极检测");
	connect(m_pushbutton_detection_electrode_right, &QPushButton::clicked, this, [=]() {
		QString message;
		HObject image = matToHImage(m_image);
		bool state = m_function_blob_match->detection(image, message);
		if (state)
		{

			m_detection_electrode_rect_right->image_in = m_function_blob_match->hobject_out;
			m_detection_electrode_rect_right->showDialog();
			m_detection_electrode_rect_right->show();
		}
		else
		{
			//QMessageBox::information(nullptr, "电极定位和提取出错", message);
			return;

		}

	});
	qgridLayout->addWidget(m_pushbutton_detection_electrode_right, index, 0);

	m_qcombobox_unuse_use_detection_electrode_right = new QComboBox(this);
	m_qcombobox_unuse_use_detection_electrode_right->setFixedSize(control_size);
	m_qcombobox_unuse_use_detection_electrode_right->addItem("右电极检测不启动");
	m_qcombobox_unuse_use_detection_electrode_right->addItem("右电极检测启动");
	qgridLayout->addWidget(m_qcombobox_unuse_use_detection_electrode_right, index, 1);

	index++;



    m_pushbutton_detection_charater = new QPushButton(this);
    m_pushbutton_detection_charater->setFixedSize(control_size);
    m_pushbutton_detection_charater->setText("字符检测");
    connect(m_pushbutton_detection_charater, &QPushButton::clicked, this, [=]() {
        QString message;
        HObject image = matToHImage(m_image);
        bool state = m_function_blob_match->detection(image, message);
        if (state)
        {

            m_detection_character->image_in = m_function_blob_match->hobject_out;
            m_detection_character->show();
        }
        else
        {
            //QMessageBox::information(nullptr, "电极定位和提取出错", message);
            return;

        }

        });
    qgridLayout->addWidget(m_pushbutton_detection_charater, index, 0);

    m_qcombobox_unuse_use_detection_charater = new QComboBox(this);
    m_qcombobox_unuse_use_detection_charater->setFixedSize(control_size);
    m_qcombobox_unuse_use_detection_charater->addItem("字符检测不启动");
    m_qcombobox_unuse_use_detection_charater->addItem("字符检测启动");
    qgridLayout->addWidget(m_qcombobox_unuse_use_detection_charater, index, 1);

    index++;
    m_pushbutton_detection_hsv = new QPushButton(this);
    m_pushbutton_detection_hsv->setFixedSize(control_size);
    m_pushbutton_detection_hsv->setText("HSV检测");
    connect(m_pushbutton_detection_hsv, &QPushButton::clicked, this, [=]() {
        QString message;
        HObject image = matToHImage(m_image);
        bool state = m_function_blob_match->detection(image, message);
        if (state)
        {
            m_detection_hsv->image_in = m_function_blob_match->hobject_out;
            m_detection_hsv->showDialog();
            m_detection_hsv->show();
        }
        else
        {
            //QMessageBox::information(nullptr, "HSV检测出错", message);
            return;

        }

        });
    qgridLayout->addWidget(m_pushbutton_detection_hsv, index, 0);

    m_qcombobox_unuse_use_detection_hsv = new QComboBox(this);
    m_qcombobox_unuse_use_detection_hsv->setFixedSize(control_size);
    m_qcombobox_unuse_use_detection_hsv->addItem("HSV检测不启动");
    m_qcombobox_unuse_use_detection_hsv->addItem("HSV检测启动");
    qgridLayout->addWidget(m_qcombobox_unuse_use_detection_hsv, index, 1);


    index++;
    m_pushbutton_detection_rgb1 = new QPushButton(this);
    m_pushbutton_detection_rgb1->setFixedSize(control_size);
    m_pushbutton_detection_rgb1->setText("本体1检测");
    connect(m_pushbutton_detection_rgb1, &QPushButton::clicked, this, [=]() {
        QString message;
        HObject image = matToHImage(m_image);
        bool state = m_function_blob_match->detection(image, message);
        if (state)
        {
            m_detection_rgb1->image_in = m_function_blob_match->hobject_out;
            m_detection_rgb1->showDialog();
            m_detection_rgb1->show();
        }
        else
        {
            //QMessageBox::information(nullptr, "本体检测出错", message);
            return;

        }

        });
    qgridLayout->addWidget(m_pushbutton_detection_rgb1, index, 0);

    m_qcombobox_unuse_use_detection_rgb1 = new QComboBox(this);
    m_qcombobox_unuse_use_detection_rgb1->setFixedSize(control_size);
    m_qcombobox_unuse_use_detection_rgb1->addItem("本体1检测不启动");
    m_qcombobox_unuse_use_detection_rgb1->addItem("本体1检测启动");
    qgridLayout->addWidget(m_qcombobox_unuse_use_detection_rgb1, index, 1);



    index++;
    m_pushbutton_detection_rgb2 = new QPushButton(this);
    m_pushbutton_detection_rgb2->setFixedSize(control_size);
    m_pushbutton_detection_rgb2->setText("本体2检测");
    connect(m_pushbutton_detection_rgb2, &QPushButton::clicked, this, [=]() {
        QString message;
        HObject image = matToHImage(m_image);
        bool state = m_function_blob_match->detection(image, message);
        if (state)
        {
            m_detection_rgb2->image_in = m_function_blob_match->hobject_out;
            m_detection_rgb2->showDialog();
            m_detection_rgb2->show();
        }
        else
        {
            //QMessageBox::information(nullptr, "本体检测出错", message);
            return;

        }

        });
    qgridLayout->addWidget(m_pushbutton_detection_rgb2, index, 0);
	m_qcombobox_unuse_use_detection_rgb2 = new QComboBox(this);
    m_qcombobox_unuse_use_detection_rgb2->setFixedSize(control_size);
    m_qcombobox_unuse_use_detection_rgb2->addItem("本体2检测不启动");
    m_qcombobox_unuse_use_detection_rgb2->addItem("本体2检测启动");
    qgridLayout->addWidget(m_qcombobox_unuse_use_detection_rgb2, index, 1);

    index++;
    m_pushbutton_detection_rgb3 = new QPushButton(this);
    m_pushbutton_detection_rgb3->setFixedSize(control_size);
    m_pushbutton_detection_rgb3->setText("本体3检测");
    connect(m_pushbutton_detection_rgb3, &QPushButton::clicked, this, [=]() {
        QString message;
        HObject image = matToHImage(m_image);
        bool state = m_function_blob_match->detection(image, message);
        if (state)
        {
            m_detection_rgb3->image_in = m_function_blob_match->hobject_out;
            m_detection_rgb3->showDialog();
            m_detection_rgb3->show();
        }
        else
        {
            //QMessageBox::information(nullptr, "本体检测出错", message);
            return;

        }

        });
    qgridLayout->addWidget(m_pushbutton_detection_rgb3, index, 0);

    m_qcombobox_unuse_use_detection_rgb3 = new QComboBox(this);
    m_qcombobox_unuse_use_detection_rgb3->setFixedSize(control_size);
    m_qcombobox_unuse_use_detection_rgb3->addItem("本体3检测不启动");
    m_qcombobox_unuse_use_detection_rgb3->addItem("本体3检测启动");
    qgridLayout->addWidget(m_qcombobox_unuse_use_detection_rgb3, index, 1);



    index++;
    m_pushbutton_detection_rgb4 = new QPushButton(this);
    m_pushbutton_detection_rgb4->setFixedSize(control_size);
    m_pushbutton_detection_rgb4->setText("本体4检测");
    connect(m_pushbutton_detection_rgb4, &QPushButton::clicked, this, [=]() {
        QString message;
        HObject image = matToHImage(m_image);
        bool state = m_function_blob_match->detection(image, message);
        if (state)
        {
            m_detection_rgb4->image_in = m_function_blob_match->hobject_out;
            m_detection_rgb4->showDialog();
            m_detection_rgb4->show();
        }
        else
        {
            //QMessageBox::information(nullptr, "本体检测出错", message);
            return;

        }

        });
    qgridLayout->addWidget(m_pushbutton_detection_rgb4, index, 0);

    m_qcombobox_unuse_use_detection_rgb4 = new QComboBox(this);
    m_qcombobox_unuse_use_detection_rgb4->setFixedSize(control_size);
    m_qcombobox_unuse_use_detection_rgb4->addItem("本体4检测不启动");
    m_qcombobox_unuse_use_detection_rgb4->addItem("本体4检测启动");
    qgridLayout->addWidget(m_qcombobox_unuse_use_detection_rgb4, index, 1);


	index++;
	m_pushbutton_detection_rgb5 = new QPushButton(this);
	m_pushbutton_detection_rgb5->setFixedSize(control_size);
	m_pushbutton_detection_rgb5->setText("本体5检测");
	connect(m_pushbutton_detection_rgb5, &QPushButton::clicked, this, [=]() {
		QString message;
		HObject image = matToHImage(m_image);
		bool state = m_function_blob_match->detection(image, message);
		if (state)
		{
			m_detection_rgb5->image_in = m_function_blob_match->hobject_out;
			m_detection_rgb5->showDialog();
			m_detection_rgb5->show();
		}
		else
		{
			//QMessageBox::information(nullptr, "本体检测出错", message);
			return;

		}

	});
	qgridLayout->addWidget(m_pushbutton_detection_rgb5, index, 0);

	m_qcombobox_unuse_use_detection_rgb5 = new QComboBox(this);
	m_qcombobox_unuse_use_detection_rgb5->setFixedSize(control_size);
	m_qcombobox_unuse_use_detection_rgb5->addItem("本体5检测不启动");
	m_qcombobox_unuse_use_detection_rgb5->addItem("本体5检测启动");
	qgridLayout->addWidget(m_qcombobox_unuse_use_detection_rgb5, index, 1);


    index++;
    m_pushbutton_dl_3 = new QPushButton(this);
    m_pushbutton_dl_3->setFixedSize(control_size);
    m_pushbutton_dl_3->setText("深度学习");
    connect(m_pushbutton_dl_3, &QPushButton::clicked, this, [=]() {
        m_function_dl_3->m_image = m_image;
        m_function_dl_3->show();
        });
    qgridLayout->addWidget(m_pushbutton_dl_3, index, 0);

    m_qcombobox_unuse_use_dl_3 = new QComboBox(this);
    m_qcombobox_unuse_use_dl_3->setFixedSize(control_size);
    m_qcombobox_unuse_use_dl_3->addItem("深度学习不启动");
    m_qcombobox_unuse_use_dl_3->addItem("深度学习启动");
    qgridLayout->addWidget(m_qcombobox_unuse_use_dl_3, index, 1);


    index++;
    m_pushbutton_detection_gray = new QPushButton(this);
    m_pushbutton_detection_gray->setFixedSize(control_size);
    m_pushbutton_detection_gray->setText("产品异常");
    connect(m_pushbutton_detection_gray, &QPushButton::clicked, this, [=]() {
        m_detection_gray->m_image = m_image;
        m_detection_gray->show();
        });
    qgridLayout->addWidget(m_pushbutton_detection_gray, index, 0);

    m_qcombobox_unuse_use_detection_gray = new QComboBox(this);
    m_qcombobox_unuse_use_detection_gray->setFixedSize(control_size);
    m_qcombobox_unuse_use_detection_gray->addItem("检测不启动");
    m_qcombobox_unuse_use_detection_gray->addItem("检测启动");
    qgridLayout->addWidget(m_qcombobox_unuse_use_detection_gray, index, 1);




    index++;
    m_qcombobox_save_wrong = new QComboBox(this);
    m_qcombobox_save_wrong->setFixedSize(control_size);
    m_qcombobox_save_wrong->addItem("不存错误图像");
    m_qcombobox_save_wrong->addItem("存错误图像");
    qgridLayout->addWidget(m_qcombobox_save_wrong, index, 0);


    m_qcombobox_save_right = new QComboBox(this);
    m_qcombobox_save_right->setFixedSize(control_size);
    m_qcombobox_save_right->addItem("不存正确图像");
    m_qcombobox_save_right->addItem("存正确图像");
    qgridLayout->addWidget(m_qcombobox_save_right, index, 1);

//    index++;
//    m_qcombobox_save_roi_wrong = new QComboBox(this);
//    m_qcombobox_save_roi_wrong->setFixedSize(control_size);
//    m_qcombobox_save_roi_wrong->addItem("不存ROI错误图像");
//    m_qcombobox_save_roi_wrong->addItem("存ROI错误图像");
//    qgridLayout->addWidget(m_qcombobox_save_roi_wrong, index, 0);


//    m_qcombobox_save_roi_right = new QComboBox(this);
//    m_qcombobox_save_roi_right->setFixedSize(control_size);
//    m_qcombobox_save_roi_right->addItem("不存ROI正确图像");
//    m_qcombobox_save_roi_right->addItem("保存ROI正确图像");
//    qgridLayout->addWidget(m_qcombobox_save_roi_right, index, 1);

//    index++;
//    m_qlabel_save_jpg_png = new QLabel();
//    m_qlabel_save_jpg_png->setText("保存格式");
//    m_qlabel_save_jpg_png->setFixedSize(control_size);
//    qgridLayout->addWidget(m_qlabel_save_jpg_png, index, 0);

//    m_qcombobox_save_jpg_png = new QComboBox(this);
//    m_qcombobox_save_jpg_png->setFixedSize(control_size);
//    m_qcombobox_save_jpg_png->addItem("jpg");
//    m_qcombobox_save_jpg_png->addItem("png");
//    qgridLayout->addWidget(m_qcombobox_save_jpg_png, index, 1);

//    index++;

//    m_qcombobox_save_wrong_label = new QComboBox(this);
//    m_qcombobox_save_wrong_label->setFixedSize(control_size);
//    m_qcombobox_save_wrong_label->addItem("不保存错误标签图像");
//    m_qcombobox_save_wrong_label->addItem("保存错误标签图像");
//    qgridLayout->addWidget(m_qcombobox_save_wrong_label, index, 0);


//    m_qcombobox_save_right_label = new QComboBox(this);
//    m_qcombobox_save_right_label->setFixedSize(control_size);
//    m_qcombobox_save_right_label->addItem("不保存正确标签图像");
//    m_qcombobox_save_right_label->addItem("保存正确标签图像");
//    qgridLayout->addWidget(m_qcombobox_save_right_label, index, 1);

    index++;
    m_pushbutton_save_parameter = new QPushButton(this);
    m_pushbutton_save_parameter->setFixedSize(control_size);
    m_pushbutton_save_parameter->setText("保存参数");
    connect(m_pushbutton_save_parameter, &QPushButton::clicked, this, &Function::saveParameter);
    qgridLayout->addWidget(m_pushbutton_save_parameter, index, 0);

    index++;
	m_pushbutton_show_orign_image = new QPushButton(this);
	m_pushbutton_show_orign_image->setFixedSize(control_size);
	m_pushbutton_show_orign_image->setText("显示原图");
	connect(m_pushbutton_show_orign_image, &QPushButton::clicked, this, [=]() {
		QImage q_image = matToQImage(m_image);
		m_view->setImage(q_image, "");
		return true;
	});
	qgridLayout->addWidget(m_pushbutton_show_orign_image, index, 0);

    m_pushbutton_detection = new QPushButton(this);
    m_pushbutton_detection->setFixedSize(control_size);
    m_pushbutton_detection->setText("检测");
    connect(m_pushbutton_detection, &QPushButton::clicked, this, &Function::detectionImage);
    qgridLayout->addWidget(m_pushbutton_detection, index, 1);

    index++;
    m_pushbutton_return = new QPushButton(this);
    m_pushbutton_return->setFixedSize(control_size);
    m_pushbutton_return->setText("退出");
    qgridLayout->addWidget(m_pushbutton_return, index, 0);


    loadParameter(m_path_para, m_section);
    if(m_unuse_use_dl_3>0)
    {
        m_function_dl_3->loadmodel();
    }

    m_detection_character = new DetectionCharacter(this, m_qsettings, "detection_character");
    m_detection_character->m_image = m_image;
    if (m_unuse_use_detection_charater)
    {
        m_detection_character->create_model();
    }


    QImage q_image = matToQImage(m_image);
    m_view->setImage(q_image, "");
}

bool Function::detection(HObject image_in, QString& message)
{
    QString msg;

	if (m_unuse_use_detection_gray == 1)
	{
		bool state = m_detection_gray->detection(image_in, msg);
		if (state ==false)
		{
            message += "产品异常";
			return false;
		}
		else
		{
			return true;
		}
	}
    int state;
    if (m_unuse_use_dl_3)
    {
        Mat image_mat = himageToMat(image_in);
        state = m_function_dl_3->detection(image_mat, message);
        if (state < 1)
        {
            message += "AI检测错误";
            return false;
        }
    }

    if (m_unuse_use_function == 0)
    {
//        message += "没有开启检测";
        return true;
    }

    state = m_function_blob_match->detection(image_in, msg);
    if (state < 1)
    {
        message += "电极定位错误";
        return false;
    }
    if (m_unuse_use_measure_electrode)
    {
        m_measure_electrode->region = m_function_blob_match->region_out;
        state = m_measure_electrode->detection(m_function_blob_match->hobject_out, message);
        if (state < 1)
        {
            message += "测量错误";
            return false;
        }
    }
    if (m_unuse_use_detection_electrode_left)
    {
       
        state = m_detection_electrode_rect_left->detection(m_function_blob_match->hobject_out, msg);
        if (state < 1)
        {
            message += "左电极检测错误";
            return false;
        }
    }
	if (m_unuse_use_detection_electrode_right)
	{

		state = m_detection_electrode_rect_right->detection(m_function_blob_match->hobject_out, msg);
		if (state < 1)
		{
			message += "右电极检测错误";
			return false;
		}
	}
    if (m_unuse_use_detection_charater)
    {
        state = m_detection_character->detection(m_function_blob_match->hobject_out, msg);
        if (state < 1)
        {
            message += "字符检测错误";
            return false;
        }
    }

    if (m_unuse_use_detection_hsv)
    {

        state = m_detection_hsv->detection(m_function_blob_match->hobject_out, msg);
        if (state < 1)
        {
            message += "HSV检测错误";
            return false;
        }
    }

    if (m_unuse_use_detection_rgb1)
    {
        state = m_detection_rgb1->detection(m_function_blob_match->hobject_out, msg);
        if (state < 1)
        {
            message = "本体1检测错误";
            return false;
        }
    }
	
	if (m_unuse_use_detection_rgb2)
	{
		state = m_detection_rgb2->detection(m_function_blob_match->hobject_out, msg);
		if (state < 1)
		{
            message = "本体2检测错误";
			return false;
		}
	}
	if (m_unuse_use_detection_rgb3)
	{
		state = m_detection_rgb3->detection(m_function_blob_match->hobject_out, msg);
		if (state < 1)
		{
			message = "本体3检测错误";
			return false;
		}
	}
	if (m_unuse_use_detection_rgb4)
	{
		state = m_detection_rgb4->detection(m_function_blob_match->hobject_out, msg);
		if (state < 1)
		{
			message = "本体4检测错误";
			return false;
		}
	}
	if (m_unuse_use_detection_rgb5)
	{
		state = m_detection_rgb5->detection(m_function_blob_match->hobject_out, msg);
		if (state < 1)
		{
			message = "本体5检测错误";
			return false;
		}
	}


    message = "OK";
    return true;
}

void Function::detectionImage()
{
    if (m_image.empty())
    {
        //QMessageBox::information(nullptr, "", "没有图像");
        return;
    }

    int64 t1 = cv::getTickCount();

    QString message;
    
    HObject image = matToHImage(m_image);
    bool state = detection(image, message);

    
    int64 t2 = cv::getTickCount();

    double m_time_use = (t2 - t1) * 1000 / getTickFrequency();
    message += "检测时间：" + QString::number(m_time_use);

    Mat image_show;
    draw(m_image,image_show);

    QImage q_image = matToQImage(image_show);
    m_view->setImage(q_image, message);
}

void Function::draw(Mat image_in, Mat& image_out)
{
	if (m_unuse_use_detection_gray == 1)
	{
		m_detection_gray->draw(image_in, image_out);
		return;
	}

    if (m_unuse_use_function)
    {

        image_out = himageToMat(m_function_blob_match->hobject_out);

        m_function_blob_match->draw(image_out, image_out);


        if (m_unuse_use_measure_electrode)
        {
            m_measure_electrode->draw(image_out, image_out);

        }
        if (m_unuse_use_detection_electrode_left)
        {
            m_detection_electrode_rect_left->draw(image_out, image_out);

        }
		if (m_unuse_use_detection_electrode_right)
		{
			m_detection_electrode_rect_right->draw(image_out, image_out);

		}
        if (m_unuse_use_detection_charater)
        {
            m_detection_character->draw(image_out, image_out);
        }
        if (m_unuse_use_detection_hsv)
        {
            m_detection_hsv->draw(image_out, image_out);
        }
        if (m_unuse_use_detection_rgb1)
        {
            m_detection_rgb1->draw(image_out, image_out);
        }
        if (m_unuse_use_detection_rgb2)
        {
            m_detection_rgb2->draw(image_out, image_out);
        }
        if (m_unuse_use_detection_rgb3)
        {
            m_detection_rgb3->draw(image_out, image_out);
        }
        if (m_unuse_use_detection_rgb4)
        {
            m_detection_rgb4->draw(image_out, image_out);
        }
        if (m_unuse_use_detection_rgb5)
        {
            m_detection_rgb5->draw(image_out, image_out);
        }
//        if (m_unuse_use_dl_3)
//		{
//            m_function_dl_3->draw(image_in, image_out);
//		}

    }
    else
    {
        image_out = image_in;
    }



    if (m_unuse_use_dl_3)
    {
        m_function_dl_3->draw(image_out, image_out);
    }
}

void Function::listViewClick(const QModelIndex& model_index)
{
    QString image_path = model_index.data().toString();

    m_image = imread(image_path.toLocal8Bit().toStdString(), IMREAD_UNCHANGED);

    if (m_image.empty())
    {
        //QMessageBox::information(nullptr, "", "加载检测图像错误");
        return;
    }
      m_function_blob_match->m_image = m_image;
      m_detection_character->m_image = m_image;
    QImage q_image = matToQImage(m_image);
    m_view->setImage(q_image, "");
}

void Function::loadParameter(QString path_in, QString section)
{
    m_path_para = path_in;
    m_section = section;
    try
    {
//        m_qspinbox_row1->setValue(m_qsettings->value(m_section + "/" + "m_qspinbox_row1",100).toInt());
//        m_qspinbox_column1->setValue(m_qsettings->value(m_section + "/" + "m_qspinbox_column1",100).toInt());
//        m_qspinbox_row2->setValue(m_qsettings->value(m_section + "/" + "m_qspinbox_row2",200).toInt());
//        m_qspinbox_column2->setValue(m_qsettings->value(m_section + "/" + "m_qspinbox_column2",200).toInt());
//        m_roi_rect.y       =  m_qspinbox_row1->value();
//        m_roi_rect.x       =  m_qspinbox_column1->value();
//        m_roi_rect.height  =  m_qspinbox_row2->value() - m_qspinbox_row1->value();
//        m_roi_rect.width   =  m_qspinbox_column2->value() -m_qspinbox_column1->value();
//        m_view->setRectPose(m_qspinbox_row1->value(), m_qspinbox_column1->value() , m_qspinbox_row2->value(), m_qspinbox_column2->value());

        m_unuse_use_function = m_qsettings->value(section + "/" + "m_unuse_use_function").toInt();
        m_unuse_use_detection_charater = m_qsettings->value(section + "/" + "m_unuse_use_detection_charater").toInt();
        m_unuse_use_measure_electrode = m_qsettings->value(section + "/" + "m_unuse_use_measure_electrode").toInt();
        m_unuse_use_detection_electrode_left = m_qsettings->value(section + "/" + "m_unuse_use_detection_electrode_left").toInt();
		m_unuse_use_detection_electrode_right = m_qsettings->value(section + "/" + "m_unuse_use_detection_electrode_right").toInt();
        m_unuse_use_detection_hsv = m_qsettings->value(section + "/" + "m_unuse_use_detection_hsv").toInt();
        m_unuse_use_detection_rgb1 = m_qsettings->value(section + "/" + "m_unuse_use_detection_rgb1").toInt();
		m_unuse_use_detection_rgb2 = m_qsettings->value(section + "/" + "m_unuse_use_detection_rgb2").toInt();
		m_unuse_use_detection_rgb3 = m_qsettings->value(section + "/" + "m_unuse_use_detection_rgb3").toInt();
		m_unuse_use_detection_rgb4 = m_qsettings->value(section + "/" + "m_unuse_use_detection_rgb4").toInt();
		m_unuse_use_detection_rgb5 = m_qsettings->value(section + "/" + "m_unuse_use_detection_rgb5").toInt();
        m_unuse_use_dl_3 = m_qsettings->value(section + "/" + "m_unuse_use_dl_3",0).toInt();
		m_unuse_use_detection_gray = m_qsettings->value(section + "/" + "m_unuse_use_detection_gray").toInt();


        m_save_wrong = m_qsettings->value(section + "/" + "m_save_wrong").toInt();
        m_save_right = m_qsettings->value(section + "/" + "m_save_right").toInt();
//        m_save_roi_wrong = m_qsettings->value(section + "/" + "m_save_roi_wrong").toInt();
//        m_save_roi_right = m_qsettings->value(section + "/" + "m_save_roi_right").toInt();
//        m_save_wrong_label = m_qsettings->value(section + "/" + "m_save_wrong_label").toInt();
//        m_save_right_label = m_qsettings->value(section + "/" + "m_save_right_label").toInt();

        m_qcombobox_unuse_use->setCurrentIndex(m_unuse_use_function);
        m_qcombobox_unuse_use_detection_charater->setCurrentIndex(m_unuse_use_detection_charater);
        m_qcombobox_unuse_use_measure_electrode->setCurrentIndex(m_unuse_use_measure_electrode);
        m_qcombobox_unuse_use_detection_electrode_left->setCurrentIndex(m_unuse_use_detection_electrode_left);
		m_qcombobox_unuse_use_detection_electrode_right->setCurrentIndex(m_unuse_use_detection_electrode_right);
        m_qcombobox_unuse_use_detection_hsv->setCurrentIndex(m_unuse_use_detection_hsv);
        m_qcombobox_unuse_use_detection_rgb1->setCurrentIndex(m_unuse_use_detection_rgb1);
		m_qcombobox_unuse_use_detection_rgb2->setCurrentIndex(m_unuse_use_detection_rgb2);
		m_qcombobox_unuse_use_detection_rgb3->setCurrentIndex(m_unuse_use_detection_rgb3);
		m_qcombobox_unuse_use_detection_rgb4->setCurrentIndex(m_unuse_use_detection_rgb4);
		m_qcombobox_unuse_use_detection_rgb5->setCurrentIndex(m_unuse_use_detection_rgb5);
        m_qcombobox_unuse_use_dl_3->setCurrentIndex(m_unuse_use_dl_3);
		m_qcombobox_unuse_use_detection_gray->setCurrentIndex(m_unuse_use_detection_gray);


        m_qcombobox_save_wrong->setCurrentIndex(m_save_wrong);
        m_qcombobox_save_right->setCurrentIndex(m_save_right);
//        m_qcombobox_save_roi_wrong->setCurrentIndex(m_save_roi_wrong);
//        m_qcombobox_save_roi_right->setCurrentIndex(m_save_roi_right);
//        m_qcombobox_save_wrong_label->setCurrentIndex(m_save_wrong_label);
//        m_qcombobox_save_right_label->setCurrentIndex(m_save_right_label);

    }
    catch (exception& error)
    {
        //QMessageBox::critical(nullptr, error.what(), m_section + "参数需要重新设置");
    }

    return;
}

void Function::saveParameter()
{
    try
    {
//        m_roi_rect.y       =  m_qspinbox_row1->value();
//        m_roi_rect.x       =  m_qspinbox_column1->value();
//        m_roi_rect.height  =  m_qspinbox_row2->value() - m_qspinbox_row1->value();
//        m_roi_rect.width   =  m_qspinbox_column2->value() -m_qspinbox_column1->value();

//        m_qsettings->setValue(m_section + "/" + "m_qspinbox_row1", m_qspinbox_row1->value());
//        m_qsettings->setValue(m_section + "/" + "m_qspinbox_column1", m_qspinbox_column1->value());
//        m_qsettings->setValue(m_section + "/" + "m_qspinbox_row2", m_qspinbox_row2->value());
//        m_qsettings->setValue(m_section + "/" + "m_qspinbox_column2", m_qspinbox_column2->value());

        m_unuse_use_function = m_qcombobox_unuse_use->currentIndex();
        m_unuse_use_detection_charater = m_qcombobox_unuse_use_detection_charater->currentIndex();
        m_unuse_use_measure_electrode = m_qcombobox_unuse_use_measure_electrode->currentIndex();
        m_unuse_use_detection_electrode_left = m_qcombobox_unuse_use_detection_electrode_left->currentIndex();
		m_unuse_use_detection_electrode_right = m_qcombobox_unuse_use_detection_electrode_right->currentIndex();
        m_unuse_use_detection_hsv       = m_qcombobox_unuse_use_detection_hsv->currentIndex();
        m_unuse_use_detection_rgb1       = m_qcombobox_unuse_use_detection_rgb1->currentIndex();
		m_unuse_use_detection_rgb2 = m_qcombobox_unuse_use_detection_rgb2->currentIndex();
		m_unuse_use_detection_rgb3 = m_qcombobox_unuse_use_detection_rgb3->currentIndex();
		m_unuse_use_detection_rgb4 = m_qcombobox_unuse_use_detection_rgb4->currentIndex();
		m_unuse_use_detection_rgb5 = m_qcombobox_unuse_use_detection_rgb5->currentIndex();
        m_unuse_use_dl_3 = m_qcombobox_unuse_use_dl_3->currentIndex();
		m_unuse_use_detection_gray = m_qcombobox_unuse_use_detection_gray->currentIndex();

        m_save_wrong = m_qcombobox_save_wrong->currentIndex();
        m_save_right = m_qcombobox_save_right->currentIndex();
//        m_save_roi_wrong = m_qcombobox_save_roi_wrong->currentIndex();
//        m_save_roi_right = m_qcombobox_save_roi_right->currentIndex();
//        m_save_wrong_label = m_qcombobox_save_wrong_label->currentIndex();
//        m_save_right_label = m_qcombobox_save_right_label->currentIndex();
//        m_save_jpg_png = m_qcombobox_save_jpg_png->currentIndex();

        m_qsettings->setValue(m_section + "/" + "m_unuse_use_function", m_unuse_use_function);
        m_qsettings->setValue(m_section + "/" + "m_unuse_use_detection_charater", m_unuse_use_detection_charater);
        m_qsettings->setValue(m_section + "/" + "m_unuse_use_measure_electrode", m_unuse_use_detection_electrode_left);
        m_qsettings->setValue(m_section + "/" + "m_unuse_use_detection_electrode_left", m_unuse_use_detection_electrode_left);
		m_qsettings->setValue(m_section + "/" + "m_unuse_use_detection_electrode_right", m_unuse_use_detection_electrode_right);
        m_qsettings->setValue(m_section + "/" + "m_unuse_use_detection_hsv", m_unuse_use_detection_hsv);
        m_qsettings->setValue(m_section + "/" + "m_unuse_use_detection_rgb1", m_unuse_use_detection_rgb1);
		m_qsettings->setValue(m_section + "/" + "m_unuse_use_detection_rgb2", m_unuse_use_detection_rgb2);
		m_qsettings->setValue(m_section + "/" + "m_unuse_use_detection_rgb3", m_unuse_use_detection_rgb3);
		m_qsettings->setValue(m_section + "/" + "m_unuse_use_detection_rgb4", m_unuse_use_detection_rgb4);
		m_qsettings->setValue(m_section + "/" + "m_unuse_use_detection_rgb5", m_unuse_use_detection_rgb5);
        m_qsettings->setValue(m_section + "/" + "m_unuse_use_dl_3", m_unuse_use_dl_3);
		m_qsettings->setValue(m_section + "/" + "m_unuse_use_detection_gray", m_unuse_use_detection_gray);


        m_qsettings->setValue(m_section + "/" + "m_save_wrong", m_save_wrong);
        m_qsettings->setValue(m_section + "/" + "m_save_right", m_save_right);
//        m_qsettings->setValue(m_section + "/" + "m_save_roi_wrong", m_save_roi_wrong);
//        m_qsettings->setValue(m_section + "/" + "m_save_roi_right", m_save_roi_right);

//        m_qsettings->setValue(m_section + "/" + "m_save_wrong_label", m_save_wrong_label);
//        m_qsettings->setValue(m_section + "/" + "m_save_right_label", m_save_right_label);

//        m_view->setRectPose(m_qspinbox_row1->value(), m_qspinbox_column1->value(), m_qspinbox_row2->value(), m_qspinbox_column2->value());
    }
    catch (exception& error)
    {
        //QMessageBox::critical(nullptr, error.what(), m_section + "参数需要重新设置");
    }
}

void Function::saveImage()
{
    if (m_image.empty())
    {
        //QMessageBox::information(nullptr, "", "加载图像错误");
        return;
    }
    imwrite(m_model_image_path.toLocal8Bit().toStdString(), m_image);
}
#pragma execution_character_set("utf-8")
